package com.hiultra.archive.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hiultra.common.annotation.Log;
import com.hiultra.common.core.controller.BaseController;
import com.hiultra.common.core.domain.AjaxResult;
import com.hiultra.common.enums.BusinessType;
import com.hiultra.archive.domain.RoomArchive;
import com.hiultra.archive.service.IRoomArchiveService;
import com.hiultra.common.utils.poi.ExcelUtil;
import com.hiultra.common.core.page.TableDataInfo;

/**
 * 盒中档案信息Controller
 *
 * @author 派大星
 * @date 2024-07-23
 */
@RestController
@RequestMapping("/archive/roomArchive")
public class RoomArchiveController extends BaseController
{
    @Autowired
    private IRoomArchiveService roomArchiveService;

    /**
     * 查询盒中档案信息列表
     */
    @PreAuthorize("@ss.hasPermi('archive:roomArchive:list')")
    @GetMapping("/list")
    public TableDataInfo list(RoomArchive roomArchive)
    {
        startPage();
        roomArchive.setDelflag("0");
        List<RoomArchive> list = roomArchiveService.selectRoomArchiveList(roomArchive);
        return getDataTable(list);
    }

    /**
     * 导出盒中档案信息列表
     */
    @PreAuthorize("@ss.hasPermi('archive:roomArchive:export')")
    @Log(title = "盒中档案信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RoomArchive roomArchive)
    {
        List<RoomArchive> list = roomArchiveService.selectRoomArchiveList(roomArchive);
        ExcelUtil<RoomArchive> util = new ExcelUtil<RoomArchive>(RoomArchive.class);
        util.exportExcel(response, list, "盒中档案信息数据");
    }

    /**
     * 获取盒中档案信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('archive:roomArchive:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(roomArchiveService.selectRoomArchiveById(id));
    }

    /**
     * 新增盒中档案信息
     */
    @PreAuthorize("@ss.hasPermi('archive:roomArchive:add')")
    @Log(title = "盒中档案信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RoomArchive roomArchive)
    {
        return toAjax(roomArchiveService.insertRoomArchive(roomArchive));
    }

    /**
     * 修改盒中档案信息
     */
    @PreAuthorize("@ss.hasPermi('archive:roomArchive:edit')")
    @Log(title = "盒中档案信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RoomArchive roomArchive)
    {
        return toAjax(roomArchiveService.updateRoomArchive(roomArchive));
    }

    /**
     * 删除盒中档案信息
     */
    @PreAuthorize("@ss.hasPermi('archive:roomArchive:remove')")
    @Log(title = "盒中档案信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(roomArchiveService.deleteRoomArchiveByIds(ids));
    }

}
